package src.data.srv;

import java.util.Set;

import src.data.daos.ClienteDAO;
import src.data.hbt.Closure;
import src.data.hbt.Executor;
import src.domain.Cliente;


public class ClienteSRV {
	private static ClienteDAO dao;
	static {
		dao = ClienteDAO.getInstance();
	}
	
	
	public Cliente getClienteById(final Long id){
		return (Cliente) Executor.execute(new Closure() {
			public Object execute() {
				Cliente c = new Cliente();
				c.setClienteId(id);
				return dao.getByID(c);
			
			}
		});
	}
	
	public void saveOrUpdateCliente(final Cliente Cliente) {
		Executor.execute(new Closure() {
			public Object execute() {
				dao.saveOrUpdate(Cliente);
				return null;
			}
		}); 

	}
	
	@SuppressWarnings("unchecked")
	public Set<Cliente> getAllClientes(){
		return(Set<Cliente>) Executor.execute(new Closure() {
			public Object execute() {
				return dao.getAll();
			}
		});
		
	}
}
